#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
map<char, int> mp;
int main()
{
    char c;
    cin >> c;
    int n;
    cin >> n;
    mp['*'] = (1 + n) * n / 2;
    mp['='] = (1 + n) * n / 2;
    mp[','] = (1 + n) * n / 2;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            if (j <= 9)
                mp[j + '0']++;
            else
            {
                int x = j;
                while (x)
                {
                    mp[(x % 10) + '0']++;
                    x /= 10;
                }
            }
            if (i <= 9)
                mp[i + '0']++;
            else
            {
                int y = i;
                while (y)
                {
                    mp[(y % 10) + '0']++;
                    y /= 10;
                }
            }
            int s = j * i;
            while (s)
            {
                mp[(s % 10) + '0']++;
                s /= 10;
            }
        }
    }
    for (auto v : mp)
    {
        if (v.first == c)
        {
            cout << v.second << endl;
            break;
        }
    }
    return 0;
}